﻿using System;
using System.Configuration;
using System.Linq;

namespace BBYOpen.Linq.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var key = ConfigurationManager.AppSettings["api-key"];
            
            var context = new RemixQueryContext(key);

            //var get = context.Products.Get(7000032);

            //Console.WriteLine("Product Name: {0}", get.Name);

            //foreach (var store in context.Stores.Area("30062", 10))
            //    Console.WriteLine("{0} {1}", store.Name, store.PostalCode);

            //var categories = from c in context.Categories
            //                 //where new[] { "test" }.Contains(c.Name)
            //                 orderby c.Id
            //                 select c;

            //int index = 10;

            //var page = categories.Page(index).ToPageable();

            ////var categories2 = categories.Where(c => c.Id == "id");

            //foreach (var category in page)
            //    Console.WriteLine("{0}", category.Name);

            //Console.WriteLine("CanonicalUrl: {0}", page.CanonicalUrl);
            //Console.WriteLine("CurrentPage: {0}", page.CurrentPage);
            //Console.WriteLine("From: {0}", page.From);
            //Console.WriteLine("Partial: {0}", page.Partial);
            //Console.WriteLine("QueryTime: {0}", page.QueryTime);
            //Console.WriteLine("To: {0}", page.To);
            //Console.WriteLine("Total: {0}", page.Total);
            //Console.WriteLine("TotalPages: {0}", page.TotalPages);
            //Console.WriteLine("TotalTime: {0}", page.TotalTime);

            var products = (from p in context.Products
                            where p.RegularPrice > 10.00D
                            && p.Type == "Software"
                            orderby p.Name
                            select p).Page(10);
            
            foreach (var product in products)
                Console.WriteLine(string.Format("Name: {0}; Price: {1}; Sale: {2}"
                    , product.Name
                    , product.RegularPrice
                    , product.SalePrice));

            Console.WriteLine("");
            Console.WriteLine("Press any key to continue...");
            Console.Read();
        }
    }
}
